package com.wudi.estate.service.impl.tolladministration;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wudi.estate.bean.ownermanagement.Personnel;
import com.wudi.estate.bean.tolladministration.Charges;
import com.wudi.estate.mapper.tolladministration.ChargesMapper;
import com.wudi.estate.service.tolladministration.ChargesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChargesServiceImpl implements ChargesService {
    @Autowired
    private ChargesMapper chargesMapper;
    @Override
    public List<Charges> selectAll() throws Exception {
        return chargesMapper.selectList(null);
    }

    @Override
    public Charges selectById(Charges p) throws Exception {
        return chargesMapper.selectById(p.getId());
    }

    @Override
    public void updateById(Charges p) throws Exception {
        chargesMapper.updateById(p);
    }

    @Override
    public void updateStateById(Charges p) throws Exception {
        Charges charges = chargesMapper.selectById(p.getId());
        if(charges.isState()==true){
            charges.setState(false);
        }
        chargesMapper.updateById(charges);
    }

    @Override
    public void insert(Charges p) throws Exception {

        chargesMapper.insert(p);
    }

    @Override
    public List<Charges> selectbyName(String id) throws Exception {
        QueryWrapper<Charges> queryWrapper = new QueryWrapper();
        queryWrapper.like("id",id);
        return chargesMapper.selectList(queryWrapper);
    }
}
